package com.hs.task.quartz;




import com.hs.task.po.BodyPassPo;
import com.hs.task.util.HttpRequestUtils;
import com.hs.task.util.JsonDateValueProcessor;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * Created by chenyq5 on 2015-12-28.
 */
@Controller
@RequestMapping("/spus")
@Component("spusTask")
public class SpusTask {

    @Value("${uploadSpusUrl}")
    private String uploadSpusUrl;

    @RequestMapping("upload")
    @ResponseBody
    public Map<String, Object> execute() {
       Map<String,Object> resultMap = new HashMap<>();
        try {
           Map<String,Object> map= new HashMap<>();
           map.put("funcId","02");
            Map<String,Object> data=new HashMap<>();
           data.put("cellPhoneNumber","9999");
            data.put("zValue",-1.5);
            data.put("tValue",-1);
            data.put("conclusion","222结论是哈哈");
            data.put("suggest","建议建议");
            data.put("testTime","2013-12-01 13:30:15");
            data.put("deviceCode","111111");
            map.put("data",data);
            JSONObject jsonObject = JSONObject.fromObject(map);
            JSONObject jsonObject1 = null;
            jsonObject1 = HttpRequestUtils.httpPost(uploadSpusUrl, jsonObject);
           System.out.println(jsonObject1.toString());

        } catch (Exception e) {
            resultMap.put("mark",-1);
            resultMap.put("msg","操作失败");
            e.printStackTrace();
        }
        return resultMap;
    }

    @RequestMapping("register")
    @ResponseBody
    public Map<String, Object> register() {
        Map<String,Object> resultMap = new HashMap<>();
        try {
            Map<String,Object> map= new HashMap<>();
            map.put("funcId","01");
            Map<String,Object> data=new HashMap<>();
            data.put("cellPhoneNumber","9999");
            data.put("name","小明");
            data.put("sex","0");
            data.put("birthday","2013.12.01");
            map.put("data",data);
            JSONObject jsonObject = JSONObject.fromObject(map);
            JSONObject jsonObject1 = null;
            jsonObject1 = HttpRequestUtils.httpPost(uploadSpusUrl, jsonObject);
            System.out.println(jsonObject1.toString());

        } catch (Exception e) {
            resultMap.put("mark",-1);
            resultMap.put("msg","操作失败");
            e.printStackTrace();
        }
        return resultMap;
    }

}
